﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.IO
{
    public static class StreamEx
    {
        public static MemoryStream GetMemStream(this Stream stream)
        {
            try
            {
                MemoryStream _ms = new MemoryStream();
                stream.Position = 0;
                stream.CopyTo(_ms);
                return _ms;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
